package com.hlk.utils;

import com.hlk.utils.redis.RedisUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author hlk
 * @version 1.0
 * @date 2021-01-08 15:53
 */
@Component
public class RedisCountUtils {
    @Autowired
    private RedisUtils redisUtils;

    /**
     * 获取缓存的值
     *
     * @param key
     * @return
     */
    public Integer getCountFromRedis(String key) {
        String str = redisUtils.get(key);

        if (StringUtils.isBlank(str)) {
            str = "0";
        }
        return Integer.valueOf(str);

    }

}
